package com.aniu.smslisten;

import android.app.Activity;
import android.app.Application;
import android.os.Bundle;
import android.util.Log;

import com.aniu.smslisten.util.LogToFile;

public class SmsListenApplication extends Application implements Application.ActivityLifecycleCallbacks {
    private static final String TAG = "SmsListenApplication";

    @Override
    public void onCreate() {
        super.onCreate();
        registerActivityLifecycleCallbacks(this);

        // Delete5天前的日志文件
        LogToFile.deleteOldLogs(this);
    }

    @Override
    public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
        LogToFile.log(this, TAG, "onActivityCreated: " + activity.getClass().getSimpleName());
    }

    @Override
    public void onActivityStarted(Activity activity) {
        LogToFile.log(this, TAG, "onActivityStarted: " + activity.getClass().getSimpleName());
    }

    @Override
    public void onActivityResumed(Activity activity) {
        LogToFile.log(this, TAG, "onActivityResumed: " + activity.getClass().getSimpleName());
    }

    @Override
    public void onActivityPaused(Activity activity) {
        LogToFile.log(this, TAG, "onActivityPaused: " + activity.getClass().getSimpleName());
    }

    @Override
    public void onActivityStopped(Activity activity) {
        LogToFile.log(this, TAG, "onActivityStopped: " + activity.getClass().getSimpleName());
    }

    @Override
    public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
        LogToFile.log(this, TAG, "onActivitySaveInstanceState: " + activity.getClass().getSimpleName());
    }

    @Override
    public void onActivityDestroyed(Activity activity) {
        LogToFile.log(this, TAG, "onActivityDestroyed: " + activity.getClass().getSimpleName());
    }
}